package com.autism.app;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import android.graphics.Color;
import android.os.Bundle;
import com.google.android.material.bottomnavigation.BottomNavigationView;

public class MainActivity extends AppCompatActivity {
    private BottomNavigationView bottomNavigationView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //设置顶部状态栏颜色
        MainActivity.this.getWindow().setStatusBarColor(Color.parseColor("#DCDCDC"));
        //为底部导航栏设置监听点击切换页面
        bottomNavigationView = findViewById(R.id.button_menu);
        bottomNavigationView.setOnNavigationItemSelectedListener( item ->{
            FragmentManager fragmentManager = getSupportFragmentManager();
            switch (item.getItemId()){
                case R.id.btn_fi:
                    fragmentManager.beginTransaction()
                            .replace(R.id.fragmentContainerView,FirstFragment.class,null)
                            .setReorderingAllowed(true)
                            .commit();
                    return true;
                case R.id.btn_se:
                    fragmentManager.beginTransaction()
                            .replace(R.id.fragmentContainerView,SecondFragment.class,null)
                            .setReorderingAllowed(true)
                            .commit();
                    return true;
                case R.id.btn_th:
                    fragmentManager.beginTransaction()
                            .replace(R.id.fragmentContainerView,ThirdFragment.class,null)
                            .setReorderingAllowed(true)
                            .commit();
                    return true;
                default:
                    return false;
            }
        } );

    }
}